home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / Pascal OS8 / AMReminder / DReminder.p < prev    next >
Encoding:
Text File  |  1998-10-30  |  4.7 KB  |  275 lines  |  [TEXT/CWIE]

  1. { DReminder.p -- data container class for AMReminder}
  2.  
  3. Unit DReminder;
  4. Interface
  5.  
  6. Uses
  7.     Types,
  8.     OSUtils,
  9.  
  10.  
  11.     AMSignaler;
  12.  
  13. const
  14.     idDateTime        = longint ('Date');
  15.     idMessage        = longint ('Mese');
  16.     idShowAlert        = longint ('Shot');
  17.     idShowIcon        = longint ('Shon');
  18.     idPlaySound        = longint ('Plad');
  19.     idSoundIndex        = longint ('Soux');
  20.     idDateString        = longint ('Datg');
  21.     idTimeString        = longint ('Timg');
  22.     idYearMonthDay        = longint ('Yeay');
  23.     idHourMinute        = longint ('Houe');
  24.  
  25. type
  26.     {----------}
  27.     DReminder    = object (AMSignaler)
  28.  
  29.     {data members}
  30.         mDateTime:        LongDateRec;
  31.         mMessage:        Str255;
  32.         mShowAlert:        Boolean;
  33.         mShowIcon:        Boolean;
  34.         mPlaySound:        Boolean;
  35.         mSoundIndex:        SInt16;
  36.  
  37.     {methods}
  38.         Procedure Initialize; Override;
  39.  
  40.         Function  GetDateTime: LongDateRec;
  41.         Procedure SetDateTime    (inValue:        LongDateRec);
  42.         Function  GetMessage: Str255;
  43.         Procedure SetMessage    (inValue:        Str255);
  44.         Function  GetShowAlert: Boolean;
  45.         Procedure SetShowAlert    (inValue:        Boolean);
  46.         Function  GetShowIcon: Boolean;
  47.         Procedure SetShowIcon    (inValue:        Boolean);
  48.         Function  GetPlaySound: Boolean;
  49.         Procedure SetPlaySound    (inValue:        Boolean);
  50.         Function  GetSoundIndex: SInt16;
  51.         Procedure SetSoundIndex    (inValue:        SInt16);
  52.         Function  GetDateString: Str255;
  53.         Procedure SetDateString    (inValue:        Str255);
  54.         Function  GetTimeString: Str255;
  55.         Procedure SetTimeString    (inValue:        Str255);
  56.         Function  GetYearMonthDay: LongDateRec;
  57.         Procedure SetYearMonthDay    (inValue:        LongDateRec);
  58.         Function  GetHourMinute: LongDateRec;
  59.         Procedure SetHourMinute    (inValue:        LongDateRec);
  60.     end;
  61.  
  62. {----------}
  63. Function NewDReminder: DReminder;
  64.  
  65. {----------}
  66. Implementation
  67.  
  68. {----------}
  69. Function NewDReminder: DReminder;
  70. var
  71.     data:        DReminder;
  72. begin
  73.     data := nil;
  74.     New (data);
  75.     if data <> nil then begin
  76.         data.Initialize;
  77.     end;
  78.     NewDReminder := data;
  79. end;
  80.  
  81. {----------}
  82. Procedure DReminder.Initialize;
  83. begin
  84.     inherited Initialize;
  85.  
  86.     mDateTime.eraAlt := 0;
  87.     GetTime (mDateTime.oldDate);
  88.     {mMessage := 0;}
  89.     mShowAlert := false;
  90.     mShowIcon := false;
  91.     mPlaySound := false;
  92.     mSoundIndex := 1;
  93. end;
  94.  
  95. {----------}
  96. Function DReminder.GetDateTime: LongDateRec;
  97. begin
  98.     GetDateTime := mDateTime;
  99.  
  100.  
  101. end;
  102.  
  103. Procedure DReminder.SetDateTime (
  104.     inValue:        LongDateRec);
  105. begin
  106.     mDateTime := inValue;
  107.  
  108.  
  109.     SignalDataChanged (idDateTime);
  110. end;
  111.  
  112. {----------}
  113. Function DReminder.GetMessage: Str255;
  114. begin
  115.     GetMessage := mMessage;
  116.  
  117.  
  118. end;
  119.  
  120. Procedure DReminder.SetMessage (
  121.     inValue:        Str255);
  122. begin
  123.     mMessage := inValue;
  124.  
  125.  
  126.     SignalDataChanged (idMessage);
  127. end;
  128.  
  129. {----------}
  130. Function DReminder.GetShowAlert: Boolean;
  131. begin
  132.     GetShowAlert := mShowAlert;
  133.  
  134.  
  135. end;
  136.  
  137. Procedure DReminder.SetShowAlert (
  138.     inValue:        Boolean);
  139. begin
  140.     mShowAlert := inValue;
  141.  
  142.  
  143.     SignalDataChanged (idShowAlert);
  144. end;
  145.  
  146. {----------}
  147. Function DReminder.GetShowIcon: Boolean;
  148. begin
  149.     GetShowIcon := mShowIcon;
  150.  
  151.  
  152. end;
  153.  
  154. Procedure DReminder.SetShowIcon (
  155.     inValue:        Boolean);
  156. begin
  157.     mShowIcon := inValue;
  158.  
  159.  
  160.     SignalDataChanged (idShowIcon);
  161. end;
  162.  
  163. {----------}
  164. Function DReminder.GetPlaySound: Boolean;
  165. begin
  166.     GetPlaySound := mPlaySound;
  167.  
  168.  
  169. end;
  170.  
  171. Procedure DReminder.SetPlaySound (
  172.     inValue:        Boolean);
  173. begin
  174.     mPlaySound := inValue;
  175.  
  176.  
  177.     SignalDataChanged (idPlaySound);
  178. end;
  179.  
  180. {----------}
  181. Function DReminder.GetSoundIndex: SInt16;
  182. begin
  183.     GetSoundIndex := mSoundIndex;
  184.  
  185.  
  186. end;
  187.  
  188. Procedure DReminder.SetSoundIndex (
  189.     inValue:        SInt16);
  190. begin
  191.     mSoundIndex := inValue;
  192.  
  193.  
  194.     SignalDataChanged (idSoundIndex);
  195. end;
  196.  
  197. {----------}
  198. Function DReminder.GetDateString: Str255;
  199. var
  200.     longSeconds:    LongDateTime;
  201.     dateString:        Str255;
  202. begin
  203.  
  204.     LongDateToSeconds (mDateTime, longSeconds);
  205.     LongDateString (longSeconds, shortDate, dateString, nil);
  206.  
  207.     GetDateString := dateString;
  208.  
  209. end;
  210.  
  211. Procedure DReminder.SetDateString (
  212.     inValue:        Str255);
  213. begin
  214.  
  215.     SignalDataChanged (idDateString);
  216. end;
  217.  
  218. {----------}
  219. Function DReminder.GetTimeString: Str255;
  220. var
  221.     longSeconds:    LongDateTime;
  222.     timeString:        Str255;
  223. begin
  224.  
  225.     LongDateToSeconds (mDateTime, longSeconds);
  226.     LongTimeString (longSeconds, false, timeString, nil);
  227.  
  228.     GetTimeString := timeString;
  229.  
  230. end;
  231.  
  232. Procedure DReminder.SetTimeString (
  233.     inValue:        Str255);
  234. begin
  235.  
  236.     SignalDataChanged (idTimeString);
  237. end;
  238.  
  239. {----------}
  240. Function DReminder.GetYearMonthDay: LongDateRec;
  241. begin
  242.     return mDateTime;
  243.  
  244. end;
  245.  
  246. Procedure DReminder.SetYearMonthDay (
  247.     inValue:        LongDateRec);
  248. begin
  249.     mDateTime.year := inValue.year;
  250.     mDateTime.month := inValue.month;
  251.     mDateTime.day := inValue.day;
  252.     SignalDataChanged (idDateTime);
  253.  
  254.     SignalDataChanged (idYearMonthDay);
  255. end;
  256.  
  257. {----------}
  258. Function DReminder.GetHourMinute: LongDateRec;
  259. begin
  260.     return mDateTime;
  261.  
  262. end;
  263.  
  264. Procedure DReminder.SetHourMinute (
  265.     inValue:        LongDateRec);
  266. begin
  267.     mDateTime.hour := inValue.hour;
  268.     mDateTime.minute := inValue.minute;
  269.     SignalDataChanged (idDateTime);
  270.  
  271.     SignalDataChanged (idHourMinute);
  272. end;
  273.  
  274. end.
  275.